<%@page import="rjeutsky.models.Publication"%>
<%@page import="rjeutsky.models.Subscription"%>
<%@page import="rjeutsky.ControllerWrapper"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="mytags" uri="/WEB-INF/tld/mytags.tld" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Неоплаченные подписки</title>
</head>
<mytags:AuthenticationLevel userLevelString="ADMIN"/>
<%
	pageContext.setAttribute("items", ControllerWrapper
			.getApplicationController().getUnpayedSubscriptions());
%>
<body>
	<table>
		<tr>
			<td><jsp:include page="Menu.jsp" /></td>
			<td><span class="info">${param.infoText}</span><span>Неоплаченные подписки</span> <c:if
					test="${items.size() > 0 }">
					<table>
						<tr>
							<th>Пользователь</th>
							<th>Издания</th>
							<th>Сумма</th>
							<th></th>
						</tr>
						<%
							for (Subscription subscription : ControllerWrapper.getApplicationController().getUnpayedSubscriptions()) {
						%>
						<tr>
							<td><%=ControllerWrapper.getApplicationController().getUser(subscription.getUserId()).getLogin()%></td>
							<td>
								<ul>
									<%
										for (Publication publication : ControllerWrapper
														.getApplicationController()
														.getSubscriptionPublications(subscription)) {
									%>
									<li><%=String.format("%1$s (%2$d)",
								publication.getName(), publication.getPrice())%></li>
									<%
										}
									%>
								</ul>
							</td>
							<td><%=ControllerWrapper.getApplicationController().GetPaymentSum(subscription) %></td>
							<td><form
									action="${pageContext.request.contextPath}/PaySubscription"
									method="post">
									<input type="hidden" name="id" value="<%=subscription.getId()%>" /><input
										type="submit" name="submit" value="Оплатить" />
								</form></td>
						</tr>
						<%
							}
						%>
					</table>
				</c:if> <c:if test="${items.size() == 0 }">Неоплаченных подписок нет</c:if>
			</td>
		</tr>
	</table>
</body>
</html>